<?php
class Shop_Model_Map extends Shop_Model_Base{

	/**
	 * 表示用変換
	 * @param $shopInfo
	 * @param $imagepath
	 */
	public function convertData($shopInfo, $imagepath, $tenpoimageurl)
	{
		$dispShopInfo = $shopInfo;
		
		// 旧店舗コード
		$dispShopInfo['OLD_TENPO_CD'] = Apm_ShopUtil::getOldTenpoCd($shopInfo['M05_TENPO_CD']);
		
		$filePath = $tenpoimageurl . 'm' . $dispShopInfo['OLD_TENPO_CD'] . ".gif";
		
		$x = get_headers($filePath);
		if (preg_match("/OK$/", $x[0]))
		//if (file_exists($filePath))
		{
			$dispShopInfo['hasFile'] = true;
			$dispShopInfo['filePath'] = $tenpoimageurl . 'm' . $dispShopInfo['OLD_TENPO_CD'] . ".gif";
		}
		else
		{
			$dispShopInfo['hasFile'] = false;
			$dispShopInfo['filePath'] = '';
		}

		return $dispShopInfo;
	}
	
    /**
     * 店舗情報取得sql文生成
     * sql文生成
     * @param $params
     * @param $db_params
     * @return sql文
     */
	protected function generateSql($params, &$db_params)
    {
    	$strShopCd = $params['ShopCd'];
    	
$sql = <<< DOC_END

	SELECT
		M05_TENPO_CD
        ,M05_TENPO_NAME
        ,NVL(M05_TENPO_TEL01, '') M05_TENPO_TEL01
        ,NVL(M05_JYUUSHO_TEXT, '') M05_JYUUSHO_TEXT
        ,NVL(M05_TENPO_BANCHI, '') M05_TENPO_BANCHI
        ,NVL(M05_TENPO_JYUUSHO_BIKOU, '') M05_TENPO_JYUUSHO_BIKOU
        ,NVL(M05_TENPO_ANNAI_COMMENT, '') M05_TENPO_ANNAI_COMMENT
    FROM
        M05TENPO_INFO
    WHERE
        M05_TENPO_CD = '{$strShopCd}'

DOC_END;
	        
        return $sql;
    }
}
?>
